package com.dbs.donatebooksystem.Service.impl;

import com.dbs.donatebooksystem.Service.UserService;
import com.dbs.donatebooksystem.mapper.userMapper;
import com.dbs.donatebooksystem.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
@Autowired
private userMapper usermapper;
    @Override
    public User login(User user) {
        return usermapper.getByAccountAndPassword(user);
    }


    @Override
    public boolean InsertUser(User user) {
        if(user.getAccount()==null||user.getNickname()==null|| user.getPassword()==null||user.getPhone()==null){
            return false;
        }
        usermapper.insert(user);
        return true;
    }
    @Override
    public void UpdateUser(User user){
        usermapper.updateById(user);
    }

    @Override
    public List<User> selectUsers(Integer id, String account,String nickname) {
        List<User> list = usermapper.selectUsers(id,account,nickname);
        return list;
    }

    @Override
    public User selectAUser(int id) {

        User user=usermapper.selectAUser(id);
        return user;
    }

    @Override
    public List<Map<String, Object>> selectUserStatu() {
        List<Map<String, Object>> list =usermapper.selectUserStatu();
        return list;
    }

    @Override
    public void deleteUser(Integer id) {
        usermapper.deleteUserById(id);
    }

    @Override
    public User selectUserByAccount(String account) {
        return usermapper.selectUserByAccount(account);
    }


}
